<template>
  <div class="myNavBox page-sidebar-wrapper" style="z-index: 2;">
    <el-row class="myLeftContainer page-sidebar-menu" style="z-index: 2">
      <el-col :span="24">
        <router-link to="/home" tag="a">
          <img src="static/images/logo1.png" alt="" class="myLogo" />
        </router-link>  
      </el-col>
      <el-col :span="24" class="myScrollBox">
        <el-menu
          @open="handleOpen"
          @select="select"
          @close="handleClose">
          <NavMenu v-if='list&&list.length>0' :subMenu='list'></NavMenu>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>

<style scoped>  
  .myLeftContainer{
    position: fixed;
    z-index: 2;
    width: 235px;
    height: 100%;
    top:0;
    overflow: hidden;
  }
  .myLogo{
    width: 100%;
    height: 90px;
  }
  .myScrollBox{
    height: 100%;
    width: 255px;
    padding-bottom: 123px;
    box-sizing: border-box;
    overflow-y:scroll; 
  }
  /*.myScrollBox::-webkit-scrollbar {  
    width:0px;
    height:0px;
  }*/
</style>

<script>
  import NavMenu from '@/components/NavMenu';
  import optVue from '../config/optVue.js';
  export default {
    data(){
      return{
        list:[]
      }
    },
    components:{
      NavMenu
    },
    created(){
      this.onGetMenu();
    },
    mounted(){
      // optVue.sliderNav(this);
      
      $(".myLeftContainer").css("min-height",$(window).height());
      $(window).resize(function(){
        $(".myLeftContainer").css("min-height",$(window).height());
      })
    },
    methods:{
      onGetMenu(){
        let vm=this;
        let menu=window.localStorage.getItem("navmenu");
        let menuJSON=JSON.parse(menu);
        vm.list=menuJSON;
      },
      transmitData:function(){
        var arrNavData=window.sessionStorage.getItem("navData");
        this.$emit('changeNavData',arrNavData.split(","));
      },
      handleOpen(key, keyPath) {
        //console.log("打开", key, keyPath);
        window.sessionStorage.setItem("navData",keyPath);
        this.transmitData();
      },
      handleClose(key, keyPath) {
        //console.log("关闭", key, keyPath);
        window.sessionStorage.setItem("navData",keyPath);
        this.transmitData();
      },
      select(key, keyPath) {
        //console.log("选中", key, keyPath);
        window.sessionStorage.setItem("navData",keyPath);
        this.transmitData();
      }
    }
  }
</script>



